<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/5/23
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script src="/layui/jquery-3.6.0.min.js"></script>
    <script>
        $(function () {
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage
                    , layer = layui.layer;
                //分组件
                laypage.render({
                    elem: 'pagesData'
                    , count: ${pageInfo.total}
                    , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    , limit: ${pageInfo.pageSize}
                    , limits: [5, 10, 15]
                    , curr:${pageInfo.pageNum}
                    , jump: function (obj,first) {
                        //首次不执行
                        if(!first){
                            if (obj.curr !=${pageInfo.pageNum}) {
                                location.href = "/videoStu/findAll?page=" + obj.curr + "&limit=" + obj.limit+"&courseName="+$("#key").val()
                            }else if(obj.limit!=${pageInfo.pageSize}){
                                location.href = "/videoStu/findAll?page=1&limit=" + obj.limit+"&courseName="+$("#key").val()
                            }
                        }

                    }
                });



            });




        })

    </script>


</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>视频列表</legend>
</fieldset>
<div class="layui-bg-gray" style="padding: 0px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">

                    <form action="/videoStu/findAll">
                        <div class="layui-input-inline" style="width:300px;">
                            <input type="text" id="key" name="courseName"  value="${value}" class="layui-input" placeholder="根据课程名称或视频标题模糊查询">
                        </div>&nbsp; &nbsp;&nbsp; &nbsp;
                        <button  class="layui-btn layui-btn-sm">
                            <i class="layui-icon layui-icon-search"></i>查询
                        </button>
                    </form>

                </div>


                <!--数据列表-->
                <table id="dataList" class="layui-table">
                    <thead>
                    <tr>
                        <th class="" style="padding-right: 0px;"><input
                                id="delAll" type="checkbox" class="icheckbox_square-blue">
                        </th>
                        <th>视频ID</th>
                        <th>课程名称</th>
                        <th>视频标题</th>
                        <th>视频文件URL</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${pageInfo.list}" var="video">
                        <tr>
                            <td><input name="ids" type="checkbox" value="${video.id}"></td>
                            <td>${video.id}</td>
                            <td>${video.courseName}</td>
                            <td>${video.title}</td>
                            <td>${video.videoUrl}</td>
                            <td>${video.getCreatedTimeStr() }</td>
                            <td class="text-center">
                                    <%--详情--%>
                                <a title="视频详情" class="layui-btn layui-btn-normal layui-btn-xs"
                                   href="${pageContext.request.contextPath}/video/show?id=${video.id}"><i
                                        class="layui-icon layui-icon-align-center"></i> </a>

                                <a title="播放视频" class="layui-btn layui-btn-normal layui-btn-xs" id="videoPlay" url="${video.videoUrl}" onclick="videoPlay('${video.videoUrl}')"><i
                                         class="layui-icon layui-icon-play"></i> </a>
                                <a title="视频下载" class="layui-btn layui-btn-normal layui-btn-xs"
                                           href="${pageContext.request.contextPath}/videoStu/download?id=${video.id}"><i
                                                class="layui-icon layui-icon-download-circle"></i> </a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <!--分页-->
                <div id="pagesData"></div>

            </div>
        </div>
    </div>
</div>
</div>
</body>
<script>

    function videoPlay(url){
            layer.open({
                type: 1, // page 层类型
                area: ['800px', '480px'],
                title: '在线播放',
                offset: 'lt',
                shade: 0.6, // 遮罩透明度
                shadeClose: false, // 点击遮罩区域，关闭弹层
                //maxmin: true, // 允许全屏最小化

                anim: 0, // 0-6 的动画形式，-1 不开启
                content: '<video width="100%"  height ="100%" src=/videoPlay/'+url+' autoplay controls></video>',
                end: function(){
                    console.log('弹层已被移除');

                }
            });
    }
</script>
</html>
